﻿// MIT License
// 开源地址：https://gitee.com/co1024/AbcMvc
// Copyright (c) 2021-2023 1024
// Abc.Mvc=Furion+EF+SqlSugar+Pear layui admin.

namespace Abc.Core.Entities;

/// <summary>
/// 用户
/// </summary>
[Comment("用户")]
[Table("Sys_User")]
[SugarIndex("Index_{table}_CreationTime", nameof(CreationTime), OrderByType.Desc)]
[SugarIndex("Index_{table}_Account", nameof(Account), OrderByType.Asc)]
[SugarIndex("Index_{table}_Email", nameof(Email), OrderByType.Asc)]
public class SysUser : FullEntityNoIdentity
{
    /// <summary>
    /// 用户名(必填)
    /// </summary>
    [Comment("用户名")]
    [MaxLength(100)]
    public string Account { get; set; }

    /// <summary>
    /// 密码
    /// </summary>
    [Comment("密码")]
    public string Pwd { get; set; }

    /// <summary>
    /// 账户类型
    /// </summary>
    [Comment("账户类型")]
    public UserType UserType { get; set; }

    /// <summary>
    /// 是否启用
    /// </summary>
    [Comment("是否启用")]
    public bool IsEnable { get; set; }

    /// <summary>
    /// 是否测试
    /// </summary>
    [Comment("是否测试")]
    public bool IsTest { get; set; }

    /// <summary>
    /// 昵称
    /// </summary>
    [Comment("昵称")]
    public string Nick { get; set; }

    /// <summary>
    /// 邮箱(必填)
    /// </summary>
    [Comment("邮箱")]
    [MaxLength(200)]
    public string Email { get; set; }

    /// <summary>
    /// 省份
    /// </summary>
    [Comment("省份")]
    public string Province { get; set; }

    /// <summary>
    /// 城市
    /// </summary>
    [Comment("城市")]
    public string City { get; set; }

    /// <summary>
    /// 镇
    /// </summary>
    [Comment("镇")]
    public string Town { get; set; }

    /// <summary>
    /// 详细地址
    /// </summary>
    [Comment("详细地址")]
    public string Address { get; set; }

    /// <summary>
    /// 联系电话
    /// </summary>
    [Comment("联系电话")]
    public string Phone { get; set; }

    /// <summary>
    /// 办公电话
    /// </summary>
    [Comment("办公电话")]
    public string Tel { get; set; }

    /// <summary>
    /// 备注
    /// </summary>
    [Comment("备注")]
    public string Remark { get; set; }

    /// <summary>
    /// 最后登录时间
    /// </summary>
    [Comment("最后登录时间")]
    public DateTimeOffset? LastLoginTime { get; set; }

    /// <summary>
    /// 最后登录IP
    /// </summary>
    [Comment("最后登录IP")]
    public string LastLoginIp { get; set; }

    /// <summary>
    /// 最后登录用户浏览器信息
    /// </summary>
    [Comment("最后登录用户浏览器信息")]
    public string LastLoginUserAgent { get; set; }

    /// <summary>
    /// 是否可以使用Sagger
    /// </summary>
    [SugarColumn(ColumnDescription = "是否可以使用Sagger", DefaultValue = "0")]
    public bool IsSwagger { get; set; }

    #region ref

    /// <summary>
    /// 多对多
    /// </summary>
    [SugarColumn(IsIgnore = true)]
    [Navigate(typeof(SysUserRole), nameof(SysUserRole.UserId), nameof(SysUserRole.RoleId))]//注意顺序
    public List<SysRole> Roles { get; set; }

    [SugarColumn(IsIgnore = true)]
    public List<SysUserRole> UserRoles { get; set; }

    #endregion ref
}